/**
 * @FileName: Send02.java
 * @Package: com.rabbitmq
 * @author lig134
 * @created 2017/3/9 13:02
 * <p>
 * Copyright 2015 ziroom
 */
package com.rabbitmq;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * <p></p>
 *消息确认功能
 * <PRE>
 * <BR>	修改记录
 * <BR>-----------------------------------------------
 * <BR>	修改日期			修改人			修改内容
 * </PRE>
 *
 * @author lig134
 * @since 1.0
 * @version 1.0
 */
public class Send02 {
    public  static void main(String[] args) throws IOException, TimeoutException {
        ConnectionFactory conn=new ConnectionFactory();
        conn.setHost("master");
        conn.setPort(5672);
        conn.setUsername("ligen");
        conn.setPassword("ligen");
//        conn.setVirtualHost("/");
        Connection conn1=conn.newConnection();

        Channel channel=conn1.createChannel();

        String queueName="queue01";
//        boolean durable=true;
        channel.queueDeclare(queueName, false, false, false, null);
        channel.basicQos(1);
        String msg="HelloWorld!";

        for (int i=0;i<5;i++){
            channel.basicPublish("", queueName, null,(msg+i).getBytes());
        }
        System.out.println("send message[" + msg + "] to " + queueName + " success!");
        channel.close();
        conn1.close();
    }
}